﻿using MediatR;
using Microsoft.AspNetCore.Mvc;
using Traceability.App.Applications.Command.IMage;
using Traceability.Domain.Entity;
using Traceability.Domain.Repository;
using Traceability.Enum;

namespace Traceability.App.Applications.CommandHand.IMage
{
    public class UpdataImageCommandHand : IRequestHandler<UpdateImageCommand, ApiResult<int>>
    {
        private readonly IBaseRepository<ImageModel> _image;

        public UpdataImageCommandHand(IBaseRepository<ImageModel> image)
        {
            _image = image;
        }



        public Task<ApiResult<int>> Handle(UpdateImageCommand request, CancellationToken cancellationToken)
        {
            var result=new ApiResult<int>();
            var m = _image.GetAll().FirstOrDefault(x => x.id == request.Id);
            if (m != null)
            {
                m.del = 1;
                _image.Update(m);
                result.Message = "删除成功";
                result.data = 1;
            }
           



            return Task.FromResult(result);
        }
    }
}
